﻿using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using TVersiPlay.Common;
using TVersiPlay.MainMenu.ViewModels;
using TVersiPlay.MainMenu.Views;
using TVersiPlay.Services;
using TVersiPlay.Common.Interfaces;

namespace TVersiPlay.MainMenu
{
    public class MainMenuModule: IModule
    {
        private IUnityContainer container;
        private IRegionManager regionManager;
        private INavigationService navigationService;

        public MainMenuModule(IUnityContainer container,IRegionManager regionManager,INavigationService navigationService)
        {
            this.container = container;
            this.regionManager = regionManager;
            this.navigationService = navigationService;
        }

        public void Initialize()
        {
            this.RegisterTypesAndServices();
            this.RegisterViewsWithRegions();       
        }
               

        private void RegisterViewsWithRegions()
        {
            this.navigationService.NavigateViewToRegion(ViewNames.MainMenuView, RegionNames.MainRegion);
            //this.regionManager.RegisterViewWithRegion(RegionNames.MainRegion,typeof(MainMenuView));
        }

        protected void RegisterTypesAndServices()
        {
            this.container.RegisterType<IView, MainMenuView>(ViewNames.MainMenuView);
            this.container.RegisterType<IMainMenuViewModel, MainMenuViewModel>();

            //////ToDo: Dont need this here because it was registered with container in the bootstrapper
            ////this.container.RegisterType<INavigationService, NavigationService>(new ContainerControlledLifetimeManager());

            //this.container.RegisterType<IEmployeesView, EmployeesView>();

            //this.container.RegisterType<IEmployeesListView, EmployeesListView>();
            //this.container.RegisterType<IEmployeesListPresenter, EmployeesListPresenter>();

            //this.container.RegisterType<IEmployeesDetailsView, EmployeesDetailsView>();
            //this.container.RegisterType<IEmployeesDetailsPresenter, EmployeesDetailsPresenter>();
        }
    }
}
